﻿using AutoMapper;
using MediatR;
using ProductionManagement.Application.Command.SendWorkersForQualityInspectionCommand;
using ProductionManagement.Domain.Dtos.SendWorkersForQualityInspectionDTOS;
using ProductionManagement.Domain.ProductionDomain;
using ProductionManagement.Infrstructre.lnterface;

namespace ProductionManagement.Application.CommandHandler.SendWorkersForQualityInspectionCommandHandlers
{
    public class SendWorkersForQualityInspectionUpdateCommandHandlers : IRequestHandler<SendWorkersForQualityInspectionUpdateCommand, int>
    {
        protected readonly IMapper mapper;
        protected readonly ISendWorkersForQualityInspectionRepository repository;

        public SendWorkersForQualityInspectionUpdateCommandHandlers(IMapper mapper, ISendWorkersForQualityInspectionRepository repository)
        {
            this.mapper = mapper;
            this.repository = repository;
        }

        public async Task<int> Handle(SendWorkersForQualityInspectionUpdateCommand request, CancellationToken cancellationToken)
        {
           return await repository.UpdAsync(mapper.Map<SendWorkersForQualityInspection>(request.dtos));
        }
    }
}
